import Cookies from 'js-cookie'

const TokenKey = `chat_${process.env.VUE_APP_ROLE}_token`

export function getToken () {
  if (Cookies.get(TokenKey)) {
    return Cookies.get(TokenKey)
  } else {
    return window.localStorage.getItem(TokenKey)
  }
}

export function setToken (token) {
  window.localStorage.setItem(TokenKey, token)
  return Cookies.set(TokenKey, token)
}

export function removeToken () {
  window.localStorage.removeItem(TokenKey)
  return Cookies.remove(TokenKey)
}
